package com.twb.core.exception;

import java.io.PrintStream;
import java.io.PrintWriter;

/** 
 * @ClassName TypeCastException 
 * @Description 类型转换异常
 
 * @author DHL
 * @date 2014年4月22日 上午8:47:29 
 */ 
@SuppressWarnings("serial")
public class TypeCastException extends RuntimeException {
	Throwable nested = null;
	public TypeCastException(){
		
	}

	public TypeCastException(String paramString){
		super(paramString);
	}

	public TypeCastException(String paramString, Throwable paramThrowable){
		super(paramString);
	    this.nested = paramThrowable;
	}

	public TypeCastException(Throwable paramThrowable){
		this.nested = paramThrowable;
	}
	
	public String getMessage(){
		if (this.nested != null)
			return super.getMessage() + " (" + this.nested.getMessage() + ")";
		return super.getMessage();
	}
	
	public String getNonNestedMessage(){
		return super.getMessage();
	}
	
	public Throwable getNested(){
		if (this.nested == null)
			return this;
		return this.nested;
	}
	
	public void printStackTrace(){
		super.printStackTrace();
	    if (this.nested != null)
	    	this.nested.printStackTrace();
	}

	public void printStackTrace(PrintStream paramPrintStream){
		super.printStackTrace(paramPrintStream);
	    if (this.nested != null)
	    	this.nested.printStackTrace(paramPrintStream);
	}

	public void printStackTrace(PrintWriter paramPrintWriter){
		super.printStackTrace(paramPrintWriter);
		if (this.nested != null)
			this.nested.printStackTrace(paramPrintWriter);
	}
}
